home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / tkern10.zip / INCLUDE\STDIO.H < prev    next >
Text File  |  1994-07-16  |  5KB  |  139 lines

  1. /*
  2.  *  This file forms part of "TKERN" - "Troy's Kernel for Windows".
  3.  *
  4.  *  Copyright (C) 1994  Troy Rollo <troy@cbme.unsw.EDU.AU>
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef    __STDIO_H
  22. #define    __STDIO_H
  23.  
  24. #ifndef __TKPROTO
  25. #include <sys/tkproto.h>
  26. #endif
  27.  
  28. #ifndef    NULL
  29. #ifdef __STDC__
  30. #define NULL 0
  31. #else
  32. #define    NULL (void *) 0
  33. #endif
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. typedef    struct
  40. {
  41.     int    fd;
  42.     unsigned flags;
  43.     int    modes;
  44.  
  45.     /* Buffering stuff */
  46.  
  47.     unsigned char    ungetchar;
  48.     int    bufsize;
  49.     int    bufidx;
  50.     int    readsize;
  51.     unsigned char    *buffer;
  52. }    FILE;
  53.  
  54. #define    __FL_ERROR    0x0001
  55. #define    __FL_EOF    0x0002
  56. #define    __FL_UNGET    0x0004
  57. #define    __FL_MODIFIED    0x0008
  58. #define    __FL_EMPTY    0x0010
  59. #define    __FL_READ    0x0020
  60. #define    __FL_WRITE    0x0040
  61.  
  62. extern    FILE    _iob[];
  63.  
  64. #define    stdin    (&_iob[0])
  65. #define    stdout    (&_iob[1])
  66. #define    stderr    (&_iob[2])
  67.  
  68. #define    EOF    ((int) -1)
  69.  
  70. /* Buffered I/O functions. We supply these */
  71. /* Input */
  72. extern    int    ungetc __TKPROTO((char __c, FILE *__fp));
  73. extern    int    getc __TKPROTO((FILE * __fp));
  74. extern    int    scanf __TKPROTO((char const *__format, ...));
  75. extern    int    fscanf __TKPROTO((FILE *__fp, char const *__format, ...));
  76. extern    int    vfscanf __TKPROTO((FILE *__fp, char const *__format, void *__arglist));
  77. extern    char    *fgets __TKPROTO((char *__buffer, int __size, FILE *__fp));
  78. extern    char    *gets __TKPROTO((char *__buffer));
  79. extern    int    fread __TKPROTO((char *__buffer, int __size, int __count, FILE *__fp));
  80.  
  81. /* Output */
  82. extern    int    putc __TKPROTO((char __c, FILE *__fp));
  83. extern    int    printf __TKPROTO((char const *__format, ...));
  84. extern    int    fprintf __TKPROTO((FILE *__fp, char const *__format, ...));
  85. extern    int    vfprintf __TKPROTO((FILE *__fp, char const *__format, void *__arglist));
  86. extern    int    fputs __TKPROTO((char const *__buffer, FILE *__fp));
  87. extern    int    puts __TKPROTO((char const *__buffer));
  88. extern    int    fwrite __TKPROTO((char const *__buffer, int __size, int __count, FILE *__fp));
  89.  
  90. /* Open/close */
  91. extern    FILE    *fopen __TKPROTO((char const *__filename, char const *__mode));
  92. extern    FILE    *fdopen __TKPROTO((int __fd, char const *__mode));
  93. extern    FILE    *freopen __TKPROTO((char const *__path, char const *__mode, FILE *__fp));
  94. extern    int    fclose __TKPROTO((FILE *__fp));
  95. extern    FILE    *tmpfile __TKPROTO((void));
  96.  
  97. /* Positioning */
  98. extern    long    ftell __TKPROTO((FILE *__fp));
  99. extern    long    fseek __TKPROTO((FILE *__fp, long __offset, int __from));
  100. extern    void    rewind __TKPROTO((FILE *__fp));
  101. extern    int    feof __TKPROTO((FILE *__fp));
  102. extern    int    ferror __TKPROTO((FILE *__fp));
  103.  
  104. /* Buffering */
  105. extern    int    fflush __TKPROTO((FILE *__fp));
  106. extern    int    flushall __TKPROTO((FILE *__fp));
  107.  
  108. #define    fileno(f)    (f)->fd
  109. #define    _fileno(f)    (f)->fd
  110.  
  111.  
  112. #define    getchar() getc(stdin)
  113. #define    ungetchar() ungetc(stdin)
  114. #define putchar(c) putc(c, stdout)
  115. #define    vprintf(f, v) vfprintf(stdout, f, v)
  116. #define    vscanf(f, v) vfscanf(stdin, f, v)
  117.  
  118. /* Other stdio functions - we expect these to be supplied by the native
  119.  * C library.
  120.  */
  121.  
  122. extern    int    system __TKPROTO((char const *__command));
  123. extern    void    perror __TKPROTO((char const *__string));
  124. extern    char    *strerror __TKPROTO((int __errno));
  125. extern    int    remove __TKPROTO((char const *__path));
  126. extern    int    rename __TKPROTO((char const *__from, char const *__to));
  127. extern    char    *sscanf __TKPROTO((char const *__string, char const *__format, ...));
  128. extern    char    *sprintf __TKPROTO((char *__string, char const *__format, ...));
  129. extern    char    *tmpnam __TKPROTO((char *__seed));
  130. extern    int    vsprintf __TKPROTO((char *__string, char const *__format, void *__arglist));
  131. extern    int    vsscanf __TKPROTO((char const *__string, char const *__format, void *__arglist));
  132.          
  133.  
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137.  
  138. #endif /* __STDIO_H */
  139.